[<<Previous Entry]
[^^Up^^]
[Next Entry>>]
[Menu]
[About The Guide]
abswrite() Write Disk Sectors
#include <dos.h>
int abswrite(drive,nsects,sectno,buffer);
int drive; Drive number
int nsects; Number of sectors
int sectno; Number of first logical sector
void *buffer; Buffer address
abswrite() writes disk sectors with DOS interrupt 0x26; it disregards
the logical structure of the disk, as well as files, directories, and
file allocation tables (FATs). 'drive' is the number of the drive
number to write (0 = A, 1 = B, etc), 'nsects' is the number of
sectors to write, 'sectno' is the number of the beginning logical
sector, and 'buffer' is the address in memory from which the data is
to be written.
Returns: 0, if successful. On error, returns -1 and sets
'errno' to the value returned in the AX register by
the DOS system call.
Notes: A single call can write a maximum of 64K from memory.
Portability: MS-DOS only.
-------------------------------- Example ---------------------------------
The following statements write to logical sectors 20 through 35 on
the disk in drive A:. If the write is successful, the sectors are
read and printed to the screen. WARNING: Do not try this example on a
disk you care about.
#include <dos.h>
#include <errno.h>
#include <ctype.h>
extern char *sys_errlist[];
char buf[16*512];
char inbuf[16*512];
int x;
main()
{
for (x = 0; x < 16*512; x++)
buf[x] = 'a';
if (abswrite(0,16,20,buf) == 0) {
absread(0,16,20,inbuf);
for (x = 0; x < 16*512; x++) {
if (isprint(inbuf[x]))
printf("%c",inbuf[x]);
if (x % 50 == 0)
printf("\n");
}
}
else
printf("%s",sys_errlist[errno]);
}
See Also:
absread()
This page created by ng2html v1.05, the Norton guide to HTML conversion utility.
Written by Dave Pearson